package com.race;

/**
 * Created by iss on 2018/3/29.
 */
public class MyArrayList<E> implements List<E> {

    private Object[] table;

    private int size;

    public MyArrayList() {
        table = new Object[10];
    }

    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size() == 0;
    }

    @Override
    public boolean contains(Object o) {
        return false;
    }

    @Override
    public boolean add(E e) {
        table[size++] = e;
        return true;
    }

    @Override
    public boolean remove(Object o) {
        return false;
    }

    @Override
    public E get(int index) {
        if (index < 0 || index >= size) {
            throw new ArrayIndexOutOfBoundsException();
        }

        return (E)table[index];
    }

    @Override
    public E set(int index, E element) {
        return null;
    }

    @Override
    public void add(int index, E element) {

    }

    @Override
    public E remove(int index) {
        return null;
    }

    public static void main(String[] args) {
        List list = new MyArrayList();
        list.add(1);
        list.add(2);
        list.add(3);

        System.out.println(list.get(0)+":"+list.get(1));
    }

}
